import { Component } from '@angular/core';
import { NavController, AlertController } from 'ionic-angular';
import { ViewLogPage } from '../viewlog/viewlog';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, private alertCtlr: AlertController) {

  }

  lblStart: string = "START";

  whenStartClick(event?: any): void {
    if( this.lblStart == "START"){
      this.lblStart = "STOP";
    }else {
      this.lblStart = "START";
    }
  }

  whenDeleteClick(event?: any): void {
    this.alertCtlr.create({
      title: 'Remove User Information',
      message: 'Please confirm to remove current user',
      buttons: [
        {
          text: 'Cancel',
        }, {
          text: 'OK',
          cssClass: 'btnDelete',
          handler: data => {
          }
        },
      ]
    }).present();
  }


  whenEditClick(event?: any): void {
    this.alertCtlr.create({
      title: 'Change user information',
      message: 'Please change user information',
      inputs: [
        {
          name: 'username',
          placeholder: 'user name'
        },
      ],
      buttons: [{
        text: 'Cancel',
      }, {
        text: 'OK',
        //cssClass: 'btnDelete',
        handler: data => {
          console.log(data)
        }
      }
      ]
    }).present();
  }

  whenPlusClick(event?: any): void {
    this.alertCtlr.create({
      title: 'Add user information',
      message: 'Please input user name',
      inputs: [
        {
          name: 'username',
          placeholder: 'user name'
        },
      ],
      buttons: [{
        text: 'Cancel',
      }, {
        text: 'OK',
        //cssClass: 'btnDelete',
        handler: data => {
          console.log(data)
        }
      }
      ]
    }).present();
  }

  whenViewLogClick(): void {
    this.navCtrl.push(ViewLogPage);
  }

}
